<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Conversion | RubyFu</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.2">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-anchors/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-expandable-chapters/expandable-chapters.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    
        <link rel="stylesheet" href="../styles/website.css">
    

        
    
    
    <link rel="next" href="../module_0x1__basic_ruby_kung_fu/extraction.html" />
    
    
    <link rel="prev" href="../module_0x1__basic_ruby_kung_fu/string.html" />
    

        <script type="text/javascript" src="../styles/header.js"></script>
    </head>
    <body>
        
        
    <div class="book"
        data-level="1.1.1"
        data-chapter-title="Conversion"
        data-filepath="module_0x1__basic_ruby_kung_fu/conversion.md"
        data-basepath=".."
        data-revision="Wed Jan 27 2016 09:00:51 GMT+0300 (AST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Module 0x0 | Introduction
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.1" data-path="contribution.html">
            
                
                    <a href="../contribution.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.</b>
                        
                        Contribution
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="0.2" data-path="beginners.html">
            
                
                    <a href="../beginners.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>0.2.</b>
                        
                        Beginners
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="0.3" data-path="required_gems.html">
            
                
                    <a href="../required_gems.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.</b>
                        
                        Required Gems
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1" data-path="module_0x1__basic_ruby_kung_fu/index.html">
            
                
                    <a href="../module_0x1__basic_ruby_kung_fu/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Module 0x1 | Basic Ruby Kung Fu
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="module_0x1__basic_ruby_kung_fu/string.html">
            
                
                    <a href="../module_0x1__basic_ruby_kung_fu/string.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        String
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.1.1" data-path="module_0x1__basic_ruby_kung_fu/conversion.html">
            
                
                    <a href="../module_0x1__basic_ruby_kung_fu/conversion.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.1.</b>
                        
                        Conversion
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="module_0x1__basic_ruby_kung_fu/extraction.html">
            
                
                    <a href="../module_0x1__basic_ruby_kung_fu/extraction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.2.</b>
                        
                        Extraction
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="module_0x1__basic_ruby_kung_fu/array.html">
            
                
                    <a href="../module_0x1__basic_ruby_kung_fu/array.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        Array
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="module_0x2__system_kung_fu/index.html">
            
                
                    <a href="../module_0x2__system_kung_fu/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Module 0x2 | System Kung Fu
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="module_0x2__system_kung_fu/command_execution.html">
            
                
                    <a href="../module_0x2__system_kung_fu/command_execution.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        Command Execution
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="module_0x2__system_kung_fu/file_manipulation.html">
            
                
                    <a href="../module_0x2__system_kung_fu/file_manipulation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        File manipulation
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="module_0x2__system_kung_fu/parsing_html,_xml,_json.html">
            
                
                    <a href="../module_0x2__system_kung_fu/parsing_html,_xml,_json.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.1.</b>
                        
                        Parsing HTML, XML, JSON
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="module_0x2__system_kung_fu/cryptography.html">
            
                
                    <a href="../module_0x2__system_kung_fu/cryptography.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        Cryptography
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="module_0x2__system_kung_fu/system_shell.html">
            
                
                    <a href="../module_0x2__system_kung_fu/system_shell.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        Remote Shell
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="module_0x2__system_kung_fu/ncatrb.html">
            
                
                    <a href="../module_0x2__system_kung_fu/ncatrb.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.1.</b>
                        
                        Ncat.rb
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="module_0x2__system_kung_fu/rce_as_a_service.html">
            
                
                    <a href="../module_0x2__system_kung_fu/rce_as_a_service.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.2.</b>
                        
                        RCE as a Service
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="module_0x2__system_kung_fu/virustotal.html">
            
                
                    <a href="../module_0x2__system_kung_fu/virustotal.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        VirusTotal
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="module_0x3__network_kung_fu/index.html">
            
                
                    <a href="../module_0x3__network_kung_fu/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Module 0x3 | Network Kung Fu
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="module_0x3__network_kung_fu/ruby_socket.html">
            
                
                    <a href="../module_0x3__network_kung_fu/ruby_socket.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        Ruby Socket
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="module_0x3__network_kung_fu/ssid_finder.html">
            
                
                    <a href="../module_0x3__network_kung_fu/ssid_finder.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        SSID Finder
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="module_0x3__network_kung_fu/ftp.html">
            
                
                    <a href="../module_0x3__network_kung_fu/ftp.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        FTP
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="module_0x3__network_kung_fu/ssh.html">
            
                
                    <a href="../module_0x3__network_kung_fu/ssh.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        SSH
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="module_0x2__system_kung_fu/email.html">
            
                
                    <a href="../module_0x2__system_kung_fu/email.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        Email
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="module_0x2__system_kung_fu/smtp_enumeration.html">
            
                
                    <a href="../module_0x2__system_kung_fu/smtp_enumeration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.1.</b>
                        
                        SMTP Enumeration
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="module_0x3__network_kung_fu/network_scanning.html">
            
                
                    <a href="../module_0x3__network_kung_fu/network_scanning.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        Network Scanning
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="module_0x3__network_kung_fu/nmap.html">
            
                
                    <a href="../module_0x3__network_kung_fu/nmap.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.1.</b>
                        
                        Nmap
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="module_0x3__network_kung_fu/dns.html">
            
                
                    <a href="../module_0x3__network_kung_fu/dns.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        DNS
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="module_0x3__network_kung_fu/dns_enumeration.html">
            
                
                    <a href="../module_0x3__network_kung_fu/dns_enumeration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.1.</b>
                        
                        DNS Enumeration
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="module_0x3__network_kung_fu/snmp_enumeration.html">
            
                
                    <a href="../module_0x3__network_kung_fu/snmp_enumeration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        SNMP Enumeration
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="module_0x3__network_kung_fu/tns_enumeration.html">
            
                
                    <a href="../module_0x3__network_kung_fu/tns_enumeration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                        Oracle TNS Enumeration
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="module_0x3__network_kung_fu/packet_manipulation.html">
            
                
                    <a href="../module_0x3__network_kung_fu/packet_manipulation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                        Packet manipulation
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.10.1" data-path="module_0x3__network_kung_fu/arp_spoofing.html">
            
                
                    <a href="../module_0x3__network_kung_fu/arp_spoofing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.1.</b>
                        
                        ARP Spoofing
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10.2" data-path="module_0x3__network_kung_fu/dns_spoofing.html">
            
                
                    <a href="../module_0x3__network_kung_fu/dns_spoofing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.2.</b>
                        
                        DNS Spoofing
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="module_0x4__web_kung_fu/index.html">
            
                
                    <a href="../module_0x4__web_kung_fu/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        Module 0x4 | Web Kung Fu
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="module_0x4__web_kung_fu/sql_injection_scanner.html">
            
                
                    <a href="../module_0x4__web_kung_fu/sql_injection_scanner.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        SQL Injection Scanner
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="module_0x4__web_kung_fu/databases.html">
            
                
                    <a href="../module_0x4__web_kung_fu/databases.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        Databases
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="module_0x4__web_kung_fu/extending_burpsuite.html">
            
                
                    <a href="../module_0x4__web_kung_fu/extending_burpsuite.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        Extending Burp Suite
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="module_0x4__web_kung_fu/browser_manipulation.html">
            
                
                    <a href="../module_0x4__web_kung_fu/browser_manipulation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        Browser Manipulation
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="module_0x4__web_kung_fu/web_servcies_and_apis.html">
            
                
                    <a href="../module_0x4__web_kung_fu/web_servcies_and_apis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        Web Services and APIs
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.5.1" data-path="module_0x4__web_kung_fu/web_services.html">
            
                
                    <a href="../module_0x4__web_kung_fu/web_services.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.1.</b>
                        
                        Interacting with Web Services
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5.2" data-path="module_0x4__web_kung_fu/interacting_with_apis.html">
            
                
                    <a href="../module_0x4__web_kung_fu/interacting_with_apis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.2.</b>
                        
                        Interacting with APIs
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.5.2.1" data-path="module_0x4__web_kung_fu/wordpress_api.html">
            
                
                    <a href="../module_0x4__web_kung_fu/wordpress_api.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.2.1.</b>
                        
                        WordPress API
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5.2.2" data-path="module_0x4__web_kung_fu/twitter_api.html">
            
                
                    <a href="../module_0x4__web_kung_fu/twitter_api.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.2.2.</b>
                        
                        Twitter API
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="module_0x4__web_kung_fu/ruby2javascript.html">
            
                
                    <a href="../module_0x4__web_kung_fu/ruby2javascript.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        Ruby 2 JavaScript
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="module_0x4__web_kung_fu/web_server_and_proxy.html">
            
                
                    <a href="../module_0x4__web_kung_fu/web_server_and_proxy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.7.</b>
                        
                        Web Server and Proxy
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="module_0x5__exploitation_kung_fu/index.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        Module 0x5 | Exploitation Kung Fu
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="module_0x5__exploitation_kung_fu/fuzzer.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/fuzzer.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        Fuzzer
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="module_0x5__exploitation_kung_fu/metasploit.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/metasploit.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        Metasploit
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.2.1" data-path="module_0x5__exploitation_kung_fu/auxiliary_module.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/auxiliary_module.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.1.</b>
                        
                        Auxiliary module
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2.2" data-path="module_0x5__exploitation_kung_fu/exploit_module.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/exploit_module.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.2.</b>
                        
                        Exploit module
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2.3" data-path="module_0x5__exploitation_kung_fu/meterpreter.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/meterpreter.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.3.</b>
                        
                        Meterpreter
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.2.3.1" data-path="module_0x5__exploitation_kung_fu/extensions.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/extensions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.3.1.</b>
                        
                        API and Extensions
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2.3.2" data-path="module_0x5__exploitation_kung_fu/meterpreter_scripting.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/meterpreter_scripting.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.3.2.</b>
                        
                        Meterpreter Scripting
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2.3.3" data-path="module_0x5__exploitation_kung_fu/railgun_api_extension.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/railgun_api_extension.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.3.3.</b>
                        
                        Railgun API Extension
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="module_0x5__exploitation_kung_fu/metasm.html">
            
                
                    <a href="../module_0x5__exploitation_kung_fu/metasm.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        metasm
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="module_0x6__forensic/index.html">
            
                
                    <a href="../module_0x6__forensic/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        Module 0x6 | Forensic Kung Fu
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="module_0x6__forensic/windows_forensic.html">
            
                
                    <a href="../module_0x6__forensic/windows_forensic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        Windows Forensic
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="module_0x6__forensic/android_forensic.html">
            
                
                    <a href="../module_0x6__forensic/android_forensic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        Android Forensic
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="module_0x3__network_kung_fu/network_traffic_analysis.html">
            
                
                    <a href="../module_0x3__network_kung_fu/network_traffic_analysis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        Network Traffic Analysis
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="module_0x6__forensic/parsing_log_files.html">
            
                
                    <a href="../module_0x6__forensic/parsing_log_files.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        Parsing Log Files
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="references/index.html">
            
                
                    <a href="../references/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        References
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="faqs/index.html">
            
                
                    <a href="../faqs/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        FAQs
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9" data-path="contributors/index.html">
            
                
                    <a href="../contributors/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        Contributors
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="contributors/todo.html">
            
                
                    <a href="../contributors/todo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        TODO
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >RubyFu</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="conversion"><a name="conversion" class="plugin-anchor" href="#conversion"><span class="fa fa-link"></span></a>Conversion</h1>
<h2 id="convert-string-to-hex"><a name="convert-string-to-hex" class="plugin-anchor" href="#convert-string-to-hex"><span class="fa fa-link"></span></a>Convert String to Hex</h2>
<p>If no prefix is needed, you just do the following </p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;Rubyfu&quot;</span>.unpack(<span class="hljs-string">&quot;H*&quot;</span>)
</code></pre>
<p>Otherwise, see the below ways </p>
<p>for a single character</p>
<pre><code class="lang-ruby"><span class="hljs-string">&apos;\x%02x&apos;</span> % <span class="hljs-string">&quot;A&quot;</span>.ord
</code></pre>
<p><strong>Note:</strong> the symbols <code>*&quot;&quot;</code> are equal of <code>.join</code></p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.unpack(<span class="hljs-string">&apos;H*&apos;</span>)[<span class="hljs-number">0</span>].scan(<span class="hljs-regexp">/.{2}/</span>).map {|h| <span class="hljs-string">&apos;\x&apos;</span>+h }.join
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.unpack(<span class="hljs-string">&apos;C*&apos;</span>).map { |c| <span class="hljs-string">&apos;\x%02x&apos;</span> % c }.join
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.split(<span class="hljs-string">&quot;&quot;</span>).map {|h| <span class="hljs-string">&apos;\x&apos;</span>+h.unpack(<span class="hljs-string">&apos;H*&apos;</span>)[<span class="hljs-number">0</span>] }*<span class="hljs-string">&quot;&quot;</span>
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.split(<span class="hljs-string">&quot;&quot;</span>).map {|c|<span class="hljs-string">&apos;\x&apos;</span> + c.ord.to_s(<span class="hljs-number">16</span>)}.join
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.split(<span class="hljs-string">&quot;&quot;</span>).map {|c|<span class="hljs-string">&apos;\x&apos;</span> + c.ord.to_s(<span class="hljs-number">16</span>)}*<span class="hljs-string">&quot;&quot;</span>
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.chars.map {|c| <span class="hljs-string">&apos;\x&apos;</span> + c.ord.to_s(<span class="hljs-number">16</span>)}*<span class="hljs-string">&quot;&quot;</span>
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.each_char.map {|c| <span class="hljs-string">&apos;\x&apos;</span>+(c.unpack(<span class="hljs-string">&apos;H*&apos;</span>)[<span class="hljs-number">0</span>])}.join
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;ABCD&quot;</span>.chars.map {|c| <span class="hljs-string">&apos;\x%x&apos;</span> % c.ord}.join
</code></pre>
<p><a href="http://king-sabri.net/?p=2613" target="_blank">Source: Ruby | Convert ASCII to HEX</a></p>
<p>Returns</p>
<pre><code>\x41\x42\x43\x44
</code></pre><h2 id="convert-hex-to-string"><a name="convert-hex-to-string" class="plugin-anchor" href="#convert-hex-to-string"><span class="fa fa-link"></span></a>Convert Hex to String</h2>
<pre><code class="lang-ruby">[<span class="hljs-string">&quot;41424344&quot;</span>].pack(<span class="hljs-string">&apos;H*&apos;</span>)
</code></pre>
<p>Return</p>
<pre><code>ABCD
</code></pre><p><strong>Note about hex:</strong> Sometimes you might face a none printable characters especially due dealing with binary raw. In this case, append <strong>(</strong><code># -*- coding: binary -*-</code><strong>)</strong> at top of your file to fix any interpretation issue.</p>
<h2 id="convert-hexreturn-address-to-littleendian-format"><a name="convert-hexreturn-address-to-littleendian-format" class="plugin-anchor" href="#convert-hexreturn-address-to-littleendian-format"><span class="fa fa-link"></span></a>Convert Hex(Return address) to Little-Endian format</h2>
<p>Little-Endian format is simply reversing the string such as reversing/backwarding &quot;Rubyfu&quot; to &quot;ufybuR&quot; which can be done by calling <code>reverse</code> method of <code>String</code> class</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;Rubyfu&quot;</span>.reverse
</code></pre>
<p>In exploitation, this is not as simple as that since we&apos;re dealing with hex values that may not represent printable characters.</p>
<p>So assume we have <code>0x77d6b141</code> return address which we&apos;ve to convert it to Little-Endian format to allow CPU to read it correctly. </p>
<p>Generally speaking, it&apos;s really a trivial task to convert <code>0x77d6b141</code> to <code>\x41\xb1\xd6\x77</code> since it&apos;s one time process but this is not the case of you have ROP chain that has to be staged in your exploit. To do so simply <code>pack</code> it as array</p>
<pre><code class="lang-ruby">[<span class="hljs-number">0x77d6b141</span>].pack(<span class="hljs-string">&apos;V&apos;</span>)
</code></pre>
<p>It happens that sometime you get an error because because of none Unicode string issue. To solve this issue, just force encoding to UTF-8 but most of the time you will not face this issue</p>
<pre><code class="lang-ruby">[<span class="hljs-number">0x77d6b141</span>].pack(<span class="hljs-string">&apos;V&apos;</span>).force_encoding(<span class="hljs-string">&quot;UTF-8&quot;</span>)
</code></pre>
<p>If you have ROP chain then it&apos;s not decent to apply this each time so you can use the first way and append <strong>(</strong><code># -*- coding: binary -*-</code><strong>)</strong> at top of your exploit file.</p>
<h2 id="endecode-base64-string"><a name="endecode-base64-string" class="plugin-anchor" href="#endecode-base64-string"><span class="fa fa-link"></span></a>En/Decode base-64 String</h2>
<p>We&apos;ll present it by many ways</p>
<p><strong>Encode string</strong></p>
<pre><code class="lang-ruby">[<span class="hljs-string">&quot;RubyFu&quot;</span>].pack(<span class="hljs-string">&apos;m0&apos;</span>)
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"><span class="hljs-keyword">require</span> <span class="hljs-string">&apos;base64&apos;</span>
<span class="hljs-constant">Base64</span>.encode64 <span class="hljs-string">&quot;RubyFu&quot;</span>
</code></pre>
<p><strong>Decode</strong></p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;UnVieUZ1&quot;</span>.unpack(<span class="hljs-string">&apos;m0&apos;</span>)
</code></pre>
<p>or</p>
<pre><code class="lang-ruby"> <span class="hljs-constant">Base64</span>.decode64 <span class="hljs-string">&quot;UnVieUZ1&quot;</span>
</code></pre>
<blockquote>
<p><strong>TIP: </strong>
The string unpack method is incredibly useful for converting data we read as strings back to their original form. To read more, visit the String class reference at www.ruby-doc.org/core/classes/String.html.</p>
</blockquote>
<h2 id="endecode-url-string"><a name="endecode-url-string" class="plugin-anchor" href="#endecode-url-string"><span class="fa fa-link"></span></a>En/Decode URL String</h2>
<p>URL encoding/decoding is something known to most people. From hacker&apos;s point of view, we need it a lot in client-side vulnerability the most. </p>
<p><strong>Encoding string</strong></p>
<pre><code class="lang-ruby"><span class="hljs-keyword">require</span> <span class="hljs-string">&apos;uri&apos;</span>
puts <span class="hljs-constant">URI</span>.encode <span class="hljs-string">&apos;http://vulnerable.site/search.aspx?txt=&quot;&gt;&lt;script&gt;alert(/Rubyfu/.source)&lt;/script&gt;&apos;</span>
</code></pre>
<p><strong>Decoding string</strong></p>
<pre><code class="lang-ruby"><span class="hljs-keyword">require</span> <span class="hljs-string">&apos;uri&apos;</span>
puts <span class="hljs-constant">URI</span>.decode <span class="hljs-string">&quot;http://vulnerable.site/search.aspx?txt=%22%3E%3Cscript%3Ealert(/Rubyfu/.source)%3C/script%3E&quot;</span>
</code></pre>
<p>You can encode/decode and none URL string, of-course.</p>
<p>The above way will encode any non URL standard strings only(ex. <code>&lt;&gt;&quot;{}</code>) however if you want to encode the full string use <code>URI.encode_www_form_component</code></p>
<pre><code class="lang-ruby">puts <span class="hljs-constant">URI</span>.encode_www_form_component <span class="hljs-string">&apos;http://vulnerable.site/search.aspx?txt=&quot;&gt;&lt;script&gt;alert(/Rubyfu/.source)&lt;/script&gt;&apos;</span>
</code></pre>
<h2 id="html-endecode"><a name="html-endecode" class="plugin-anchor" href="#html-endecode"><span class="fa fa-link"></span></a>HTML En/Decode</h2>
<p><strong>Encoding HTML</strong></p>
<pre><code class="lang-ruby"><span class="hljs-keyword">require</span> <span class="hljs-string">&apos;cgi&apos;</span>
<span class="hljs-constant">CGI</span>.escapeHTML(<span class="hljs-string">&apos;&quot;&gt;&lt;script&gt;alert(&quot;Rubyfu!&quot;)&lt;/script&gt;&apos;</span>)
</code></pre>
<p>Returns </p>
<pre><code>&amp;quot;&amp;gt;&amp;lt;script&amp;gt;alert(&amp;quot;Rubyfu!&amp;quot;)&amp;lt;/script&amp;gt;
</code></pre><p><strong>Decoding HTML</strong></p>
<pre><code class="lang-ruby"><span class="hljs-keyword">require</span> <span class="hljs-string">&apos;cgi&apos;</span>
<span class="hljs-constant">CGI</span>.unescapeHTML(<span class="hljs-string">&quot;&amp;quot;&amp;gt;&amp;lt;script&amp;gt;alert(&amp;quot;Rubyfu!&amp;quot;)&amp;lt;/script&amp;gt;&quot;</span>)
</code></pre>
<p>Returns </p>
<pre><code>&quot;&gt;&lt;script&gt;alert(&quot;Rubyfu!&quot;)&lt;/script&gt;
</code></pre><h2 id="endecode-saml-string"><a name="endecode-saml-string" class="plugin-anchor" href="#endecode-saml-string"><span class="fa fa-link"></span></a>En/Decode SAML String</h2>
<p><strong>Decoding SAML</strong></p>
<pre><code class="lang-ruby"><span class="hljs-comment"># SAML Request </span>
saml = <span class="hljs-string">&quot;fZJNT%2BMwEIbvSPwHy%2Fd8tMvHympSdUGISuwS0cCBm%2BtMUwfbk%2FU4zfLvSVMq2Euv45n3fd7xzOb%2FrGE78KTRZXwSp5yBU1hpV2f8ubyLfvJ5fn42I2lNKxZd2Lon%2BNsBBTZMOhLjQ8Y77wRK0iSctEAiKLFa%2FH4Q0zgVrceACg1ny9uMy7rCdaM2%2Bs0BWrtppK2UAdeoVjW2ruq1bevGImcvR6zpHmtJ1MHSUZAuDKU0vY7Si2h6VU5%2BiMuJuLx65az4dPql3SHBKaz1oYnEfVkWUfG4KkeBna7A%2Fxm6M14j1gZihZazBRH4MODcoKPOgl%2BB32kFz08PGd%2BG0JJIkr7v46%2BhRCaEpod17DCRivYZCkmkd4N28B3wfNyrGKP5bws9DS6PKDz%2FMpsl36Tyz%2F%2Fax1jeFmi0emcLY7C%2F8SDD0Z7dobcynHbbV3QVbcZW0TlqQemNhoqzJD%2B4%2Fn8Yw7l8AA%3D%3D&quot;</span>

<span class="hljs-keyword">require</span> <span class="hljs-string">&apos;cgi&apos;</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">&apos;base64&apos;</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">&apos;zlib&apos;</span>

inflated = <span class="hljs-constant">Base64::</span>decode64(<span class="hljs-constant">CGI</span>.unescape(saml))
<span class="hljs-comment"># You don&apos;t need below code if it&apos;s not deflated/compressed</span>
zlib = <span class="hljs-constant">Zlib::Inflate</span>.new(-<span class="hljs-constant">Zlib::MAX_WBITS</span>)
zlib.inflate(inflated)
</code></pre>
<p>Returns</p>
<pre><code class="lang-ruby"><span class="hljs-string">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;\r\n&lt;samlp:AuthnRequest xmlns:samlp=\&quot;urn:oasis:names:tc:SAML:2.0:protocol\&quot; ID=\&quot;agdobjcfikneommfjamdclenjcpcjmgdgbmpgjmo\&quot; Version=\&quot;2.0\&quot; IssueInstant=\&quot;2007-04-26T13:51:56Z\&quot; ProtocolBinding=\&quot;urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\&quot; ProviderName=\&quot;google.com\&quot; AssertionConsumerServiceURL=\&quot;https://www.google.com/a/solweb.no/acs\&quot; IsPassive=\&quot;true\&quot;&gt;&lt;saml:Issuer xmlns:saml=\&quot;urn:oasis:names:tc:SAML:2.0:assertion\&quot;&gt;google.com&lt;/saml:Issuer&gt;&lt;samlp:NameIDPolicy AllowCreate=\&quot;true\&quot; Format=\&quot;urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified\&quot; /&gt;&lt;/samlp:AuthnRequest&gt;\r\n&quot;</span>
</code></pre>
<p><a href="http://stackoverflow.com/questions/3253298/base64-decode64-in-ruby-returning-strange-results" target="_blank">Source</a></p>
<p><a href="http://dev.gettinderbox.com/2013/12/16/introduction-to-saml/" target="_blank">More about SAML</a></p>
<h2 id=""><a name="" class="plugin-anchor" href="#"><span class="fa fa-link"></span></a><br><br><br></h2>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../module_0x1__basic_ruby_kung_fu/string.html" class="navigation navigation-prev " aria-label="Previous page: String"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../module_0x1__basic_ruby_kung_fu/extraction.html" class="navigation navigation-next " aria-label="Next page: Extraction"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-book-summary-scroll-position-saver/book-summary-scroll-position-saver.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"addcssjs":{"js":["styles/header.js"]},"anchors":{},"todo":{},"splitter":{},"book-summary-scroll-position-saver":{},"expandable-chapters":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
